var express = require('express');
var router = express.Router();
var db = require('./conn');//先引入数据库链接

router.get('/', function(req, resCom) {
    var username = req.param('username');
    var talkabout = req.param('talkabout');
    var bookname = req.param('bookname');

    db.pool.getConnection(function(err, connection) {
        var sql = 'insert into bbs(UserName,talkabout,bookname) values(?,?,?)';
        var sql_val = [username, talkabout, bookname];

        connection.query(sql, sql_val, function(err, result) {
            if (err) {
                console.log("您已评价");
                resCom.render('readbook', {
                    title: 'readbook'
                });
            } else {
                resCom.redirect("readerGarden");
            }

        });
        connection.release();
    });

});


module.exports = router;